package com.swiftride.pojo.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

@Data
public class OrderDetailVo {

    private Long orderId;

    private String orderNo;

    //---------- 乘客资料 ----------
    private String customerPhoto;

    private String customerName;

    private String customerPhone;

    private String carType;

    private String carPlate;

    //---------- 司机资料 ----------
    private Long driverId;

    private String driverPhoto;

    private String driverName;

    private String driverPhone;

    //---------- 订单信息 ----------
    private String startPlace;

    private String startPlaceLongitude;

    private String startPlaceLatitude;

    private String endPlace;

    private String endPlaceLongitude;

    private String endPlaceLatitude;

    //---------- 订单状态信息 ----------
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date acceptTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date arriveTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date startTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date endTime;

    private Integer status;

    private String remark;

    //---------- 订单实际 ----------
    private BigDecimal realMileage;

    private BigDecimal returnMileage;

    private BigDecimal realOrderAmount;

    //---------- 订单奖励 ----------
    private BigDecimal favourAmount;

    private BigDecimal incentiveAmount;

    //---------- 订单基础费用 ----------
    private BigDecimal baseMileage;

    private BigDecimal baseMileageAmount;

    private BigDecimal exceedBaseMileageAmount;

    private BigDecimal mileageAmount;

    private Integer waitingMinute;

    private Integer freeBaseWaitingMinute;

    private BigDecimal exceedEveryMinuteAmount;

    private BigDecimal waitingAmount;

    private BigDecimal freeBaseReturnMileage;

    private BigDecimal exceedBaseReturnEveryKmAmount;

    private BigDecimal returnAmount;
    //---------- 订单额外费用 ----------
    private BigDecimal tollAmount;

    private BigDecimal parkingAmount;

    private BigDecimal voucherAmount;

    private BigDecimal otherAmount;

    private String orderDetail;

    private BigDecimal realPayAmount;

    //---------- 订单分账 ----------
    private BigDecimal platformIncome;

    private BigDecimal driverIncome;

    private BigDecimal platformRate;

    private BigDecimal driverRate;

    public BigDecimal getExceedBaseMileage() {
        BigDecimal exceedBaseMileage = this.realMileage.subtract(this.baseMileage);
        return exceedBaseMileage.compareTo(BigDecimal.ZERO) > 0 ? exceedBaseMileage : BigDecimal.ZERO;
    }

    public Integer getExceedBaseWaitingMinute() {
        int exceedBaseWaitingMinute = this.waitingMinute - this.freeBaseWaitingMinute;
        return Math.max(exceedBaseWaitingMinute, 0);
    }

    public BigDecimal getExceedBaseReturnMileage() {
        BigDecimal exceedBaseReturnMileage = this.returnMileage.subtract(this.freeBaseReturnMileage);
        return exceedBaseReturnMileage.compareTo(BigDecimal.ZERO) > 0 ? exceedBaseReturnMileage : BigDecimal.ZERO;
    }
}
